/** @file               sw_errno.h
 *  @copyright          Copyright (C) 2006-2026 flyfish (tenggui_fu@126.com)
 *  @brief              This file is part of the swallow library
 *  @author             $Author: flyfish $
 *  @version            $Rev: 385 $
 *  @date               $Date: 2016-12-22 00:12:05 +0800 (周四, 22 12月 2016) $
 */
#ifndef __SW_ERRNO_H__
#define __SW_ERRNO_H__

#ifdef __cplusplus
extern "C" {
#endif

typedef enum _SW_ERRNO
{
    SW_E_SUCCESS,            /**< Success */
    SW_E_PERM = 10001,       /**< Operation not permitted */   
    SW_E_NOENT,              /**< No such file or directory */ 
    SW_E_SRCH,               /**< No such process */                  
    SW_E_INTR,               /**< Interrupted function call */        
    SW_E_IO,                 /**< Input/output error */               
    SW_E_NXIO,               /**< No such device or address */        
    SW_E_2BIG,               /**< Arg list too long */                
    SW_E_NOEXEC,             /**< Exec format error */                
    SW_E_BADF,               /**< Bad file descriptor */              
    SW_E_CHILD,              /**< No child processes */               
    SW_E_AGAIN,              /**< Resource temporarily unavailable */ 
    SW_E_NOMEM,              /**< Not enough space */                 
    SW_E_ACCES,              /**< Permission denied */                
    SW_E_FAULT,              /**< Bad address */                      
    SW_E_NOTBLK,             /**< Block device required */
    SW_E_BUSY,               /**< Device or resource busy */  
    SW_E_EXIST,              /**< File exists */                         
    SW_E_XDEV,               /**< Improper link (cross-device link?) */  
    SW_E_NODEV,              /**< No such device */                      
    SW_E_NOTDIR,             /**< Not a directory */                     
    SW_E_ISDIR,              /**< Is a directory */                      
    SW_E_INVAL,              /**< Invalid argument */                    
    SW_E_NFILE,              /**< Too many open files in system */       
    SW_E_MFILE,              /**< Too many open files */                 
    SW_E_NOTTY,              /**< Inappropriate I/O control operation */ 
    SW_E_TXTBSY,             /**< Text file busy */
    SW_E_FBIG,               /**< File too large */                        
    SW_E_NOSPC,              /**< No space left on device */               
    SW_E_SPIPE,              /**< Invalid seek (seek on a pipe?) */        
    SW_E_ROFS,               /**< Read-only file system */                 
    SW_E_MLINK,              /**< Too many links */                        
    SW_E_PIPE,               /**< Broken pipe */                           
    SW_E_DOM,                /**< Domain error (math functions) */         
    SW_E_RANGE,              /**< Result too large (possibly too small) */ 
    SW_E_DEADLK,             /**< Resource deadlock would occur */                                   
    SW_E_NAMETOOLONG,        /**< File name too long */                                              
    SW_E_NOLCK,              /**< No record locks available */                                       
    SW_E_NOSYS,              /**< Function not implemented */                                        
    SW_E_NOTEMPTY,           /**< Directory not empty */                                             
    SW_E_LOOP,               /**< Too many symbolic links encountered */                             
    SW_E_WOULDBLOCK,         /**< Operation would block */                                           
    SW_E_NOMSG,              /**< No message of desired type */                                      
    SW_E_IDRM,               /**< Identifier removed */                                              
    SW_E_CHRNG,              /**< Channel number out of range */                                     
    SW_E_L2NSYNC,            /**< Level 2 not synchronized */                                        
    SW_E_L3HLT,              /**< Level 3 halted */                                                  
    SW_E_L3RST,              /**< Level 3 reset */                                                   
    SW_E_LNRNG,              /**< Link number out of range */                                        
    SW_E_UNATCH,             /**< Protocol driver not attached */                                    
    SW_E_NOCSI,              /**< No CSI structure available */                                      
    SW_E_L2HLT,              /**< Level 2 halted */                                                  
    SW_E_BADE,               /**< Invalid exchange */                                                
    SW_E_BADR,               /**< Invalid request descriptor */                                      
    SW_E_XFULL,              /**< Exchange full */                                                   
    SW_E_NOANO,              /**< No anode */                                                        
    SW_E_BADRQC,             /**< Invalid request code */                                            
    SW_E_BADSLT,             /**< Invalid slot */                                                    
    SW_E_DEADLOCK,           /**< Resource deadlock would occur */                                                                 
    SW_E_BFONT,              /**< Bad font file format */                                            
    SW_E_NOSTR,              /**< Device not a stream */                                             
    SW_E_NODATA,             /**< No data available */                                               
    SW_E_TIME,               /**< Timer expired */                                                   
    SW_E_NOSR,               /**< Out of streams resources */                                        
    SW_E_NONET,              /**< Machine is not on the network */                                   
    SW_E_NOPKG,              /**< Package not installed */                                           
    SW_E_REMOTE,             /**< Object is remote */                                                
    SW_E_NOLINK,             /**< Link has been severed */                                           
    SW_E_ADV,                /**< Advertise error */                                                 
    SW_E_SRMNT,              /**< Srmount error */                                                   
    SW_E_COMM,               /**< Communication error on send */                                     
    SW_E_PROTO,              /**< Protocol error */                                                  
    SW_E_MULTIHOP,           /**< Multihop attempted */                                              
    SW_E_DOTDOT,             /**< RFS specific error */                                              
    SW_E_BADMSG,             /**< Not a data message */                                              
    SW_E_OVERFLOW,           /**< Value too large for defined data type */                           
    SW_E_NOTUNIQ,            /**< Name not unique on network */                                      
    SW_E_BADFD,              /**< File descriptor in bad state */                                    
    SW_E_REMCHG,             /**< Remote address changed */                                          
    SW_E_LIBACC,             /**< Can not access a needed shared library */                          
    SW_E_LIBBAD,             /**< Accessing a corrupted shared library */                            
    SW_E_LIBSCN,             /**< .lib section in a.out corrupted */                                 
    SW_E_LIBMAX,             /**< Attempting to link in too many shared libraries */                 
    SW_E_LIBEXEC,            /**< Cannot exec a shared library directly */                           
    SW_E_ILSEQ,              /**< Illegal byte sequence */                                           
    SW_E_RESTART,            /**< Interrupted system call should be restarted */                     
    SW_E_STRPIPE,            /**< Streams pipe error */                                              
    SW_E_USERS,              /**< Too many users */                                                  
    SW_E_NOTSOCK,            /**< Socket operation on non-socket */                                  
    SW_E_DESTADDRREQ,        /**< Destination address required */                                    
    SW_E_MSGSIZE,            /**< Message too long */                                                
    SW_E_PROTOTYPE,          /**< Protocol wrong type for socket */                                  
    SW_E_NOPROTOOPT,         /**< Protocol not available */                                          
    SW_E_PROTONOSUPPORT,     /**< Protocol not supported */    
    SW_E_SOCKTNOSUPPORT,     /**< Socket type not supported */ 
    SW_E_OPNOTSUPP,          /**< Operation not supported on transport endpoint */
    SW_E_PFNOSUPPORT,        /**< Protocol family not supported */            
    SW_E_AFNOSUPPORT,        /**< Address family not supported by protocol */
    SW_E_ADDRINUSE,          /**< Address already in use */
    SW_E_ADDRNOTAVAIL,       /**< Cannot assign requested address */              
    SW_E_NETDOWN,            /**< Network is down */                              
    SW_E_NETUNREACH,         /**< Network is unreachable */                       
    SW_E_NETRESET,           /**< Network dropped connection because of reset */  
    SW_E_CONNABORTED,        /**< Software caused connection abort */             
    SW_E_CONNRESET,          /**< Connection reset by peer */                     
    SW_E_NOBUFS,             /**< No buffer space available */                    
    SW_E_ISCONN,             /**< Transport endpoint is already connected */      
    SW_E_NOTCONN,            /**< Transport endpoint is not connected */          
    SW_E_SHUTDOWN,           /**< Cannot send after transport endpoint shutdown */
    SW_E_TOOMANYREFS,        /**< Too many references: cannot splice */           
    SW_E_TIMEDOUT,           /**< Connection timed out */                         
    SW_E_CONNREFUSED,        /**< Connection refused */                           
    SW_E_HOSTDOWN,           /**< Host is down */                                 
    SW_E_HOSTUNREACH,        /**< No route to host */                             
    SW_E_ALREADY,            /**< Operation already in progress */                
    SW_E_INPROGRESS,         /**< Operation now in progress */                    
    SW_E_STALE,              /**< Stale NFS file handle */                        
    SW_E_UCLEAN,             /**< Structure needs cleaning */                     
    SW_E_NOTNAM,             /**< Not a XENIX named type file */                  
    SW_E_NAVAIL,             /**< No XENIX semaphores available */                
    SW_E_ISNAM,              /**< Is a named type file */                         
    SW_E_REMOTEIO,           /**< Remote I/O error */                             
    SW_E_DQUOT,              /**< Quota exceeded */                               
    SW_E_NOMEDIUM,           /**< No medium found */                              
    SW_E_MEDIUMTYPE,         /**< Wrong medium type */                            
    SW_E_CANCELED,           /**< Operation Canceled */                           
    SW_E_NOKEY,              /**< Required key not available */                   
    SW_E_KEYEXPIRED,         /**< Key has expired */                              
    SW_E_KEYREVOKED,         /**< Key has been revoked */                         
    SW_E_KEYREJECTED,        /**< Key was rejected by service */                  
    SW_E_OWNERDEAD,          /**< Owner died */                                   
    SW_E_NOTRECOVERABLE,     /**< State not recoverable */
    SW_E_SYSCALL,            /**< System call error */
    SW_E_SWCALL,             /**< Swallow call error */
    SW_E_EXCALL,             /**< Extra library call error */
    SW_E_USERCALL,           /**< User defined call error */
    SW_E_TX,                 /**< TX error */
    SW_E_RX                  /**< RX error */
}SW_ERRNO;

SW_API SW_RET SW_InitErrnoAPI(SW_VOID);
SW_API SW_RET SW_RunErrnoAPI(SW_VOID);
SW_API SW_RET SW_StopErrnoAPI(SW_VOID);
SW_API SW_RET SW_ExitErrnoAPI(SW_VOID);
SW_API SW_RET SW_SetLastErrno(SW_ERRNO swerrno);
SW_API SW_ERRNO SW_GetLastErrno(SW_VOID);

#ifdef __cplusplus
}
#endif

#endif
